<?php

/**
 * Subclass for performing query and update operations on the 'product' table.
 *
 * 
 *
 * @package lib.model
 */ 
class ProductPeer extends BaseProductPeer
{
  public static function search($search){
  	$categorys = sfConfig::get('app_product_categories');

  	$c = new Criteria();
  	
  	if(isset($search['product_name']))
  	  $c->add(self::PRODUCT_NAME,'%'.$search['product_name'].'%',Criteria::LIKE);
  	
  	if(isset($search['article_code']))
  	  $c->add(self::ARTICLE_CODE,'%'.$search['article_code'].'%',Criteria::LIKE);
  	
  	  if(isset($search['color_code']))
  	  $c->add(self::COLOR_CODE,'%'.$search['color_code'].'%',Criteria::LIKE);
  	  
  	if(isset($search['color_name']))
  	  $c->add(self::COLOR_NAME,'%'.$search['color_name'].'%',Criteria::LIKE);
  	  
  	if(isset($search['product_size']))
  	  $c->add(self::PRODUCT_SIZE,'%'.$search['product_size'].'%',Criteria::LIKE);
 	//maybe do a usort?
  	$c->addAscendingOrderbyColumn(self::PRODUCT_NAME);  
  	  
  	return self::doSelect($c);
  }
}
